#!/usr/bin/pwsh
[cmdletbinding()]
param(
    [parameter(Mandatory=$True)]
    [validateset('gdb', 'lldb', 'other')]
    [string] $option
)
Push-Location
# 对于 LLDB，推荐使用 launch.json 配置 VSCODE-LLDB 插件进行调试
enum DEBUGGER_ENUM {gdb; lldb; other}
[DEBUGGER_ENUM] $debugger = $option
Set-Location $PSScriptRoot/..
if ($debugger -eq [DEBUGGER_ENUM]::gdb)
{
    Start-Process -FilePath gdb -ArgumentList "--command=./emulation/commands.gdb"
}
elseif ($debugger -eq [DEBUGGER_ENUM]::lldb)
{
    Start-Process -FilePath lldb -ArgumentList "--source ./emulation/commands.lldb"
}
Start-Process -FilePath qemu-system-i386 -ArgumentList "-S -gdb tcp::1234 -drive file=./build/SimpleOS.img,format=raw,media=disk,index=0"
Pop-Location
